<?php
use yii\helpers\Html;
use yii\helpers\Url;
use yii\widgets\LinkPager;

?>
<style>
   .listInfo li:not(:first-child):before{
       content: ',';
       margin: 0 8px;
   }
</style>
<div class="row">
    <div class="container lh30">
        <a class="topNav" href="<?=Url::toRoute('/system/site/index')?>" style=""><img src="<?=Yii::getAlias('@web/backend/img/home/home.png');?>" alt="首页"/>返回首页</a>
    </div>
</div>

<div class="row nav-brand-bg borB">
    <div class="container lh30">
        <ul class="nav nav-tabs">
            <li><a href="<?=Url::toRoute(['repertory/repertorymanage']) ?>" style="">库存管理</a></li>
            <li><a href="<?=Url::toRoute(['repertoryinc/storage','type' => 1]) ?>" style="">商品入库</a></li>
            <li><a href="<?=Url::toRoute(['goodsdec/repertoryout','type' => 1]) ?>">商品出库</a></li>
            <li><a href="<?=Url::toRoute(['repertoryinc/increcord']) ?>">入库流水</a></li>
            <li class="active"><a href="<?=Url::toRoute(['goodsdec/decrecord']) ?>">出库流水</a></li>
        </ul>
    </div>
</div>


<div class="tab-content">
    <div id="income" class="row tab-pane in active fade">

        <div class="container">
            <div>

            </div>
            <form class="" role="form" action="" method="get">
            <div class="mg20-y lh45 list clearfix" style=" word-spacing: -6px;">
                <span class="mr20">日期</span>
                <input class="lh45 laydate-icon" type="text" name="start_time" value="<?=$start_time?>" onclick="laydate()"/>
                <span class="mg20-x">至</span>
                <input class="lh45 laydate-icon" type="text" name="end_time" value="<?=$end_time?>" onclick="laydate()"/>
                <span class="mg20-x">类型</span>
                <div class="select lh45 mr20" style="vertical-align: bottom;">
                    <select  name="dec_type" id="">
                        <option value="-10000" <?php if($type == -10000){?>selected="selected"<?php }?>>全部</option>
                        <option value="1" <?php if($type == 1){?>selected="selected"<?php }?>>其他</option>
                        <option value="2" <?php if($type == 2){?>selected="selected"<?php }?>>报废/破损/过期</option>
                        <option value="3" <?php if($type == 3){?>selected="selected"<?php }?>>赠送</option>
                        <option value="4" <?php if($type == 4){?>selected="selected"<?php }?>>调拨</option>
                        <option value="5" <?php if($type == 5){?>selected="selected"<?php }?>>售卖</option>
                        <option value="6" <?php if($type == 6){?>selected="selected"<?php }?>>使用</option>
                    </select>
                </div>
                <a class="btnBg mr20" style="width: 75px; color: #fff;border-radius: 6px; height: 45px;">
                    <input type="submit" value="搜索" style="display: block; width: 100%; background: 0;border:0;line-height: 45px; font-size: 17px;">
                </a>
                <a class="btnBg dis text-center lh45" href="<?= Url::toRoute(['goodsdec/decexcel']) ?>"><img
                        src="<?= Yii::getAlias('@web/backend/img/stocks/excel.png'); ?>" alt=""
                        style="margin-right: 9px;vertical-align: text-top;"/>导出EXCEL</a>
            </div>
            </form>
            <?php if(empty($data)){?>
            <table class="table table-bordered mt20">
                <thead>
                    <tr>
                        <th>日期</th>
                        <th>类型</th>
                        <th>共计数量</th>
                        <th>出库明细</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td colspan="5" align="center"><img src="<?=Yii::getAlias('@web/backend/img/nodata.gif');?>"></td>
                    </tr>
                </tbody>
            </table>
            <?php }else{?>
            <table class="table table-bordered mt20">
                <thead>
                <tr>
                    <th>日期</th>
                    <th>类型</th>
                    <th>共计数量</th>
                    <th>出库明细</th>
                    <th>操作</th>
                </tr>
                </thead>

                <tbody>
                <?php foreach ($data as $d){?>
                <tr>
                    <td><?=Html::encode(substr($d['date'], 0,10)) ?></td>
                    <td>
                        <?php if($d['type'] == 1){?>
                                                                                                                    其他
                        <?php }elseif ($d['type'] == 2){?>
                                                                                                                  报废/破损/过期
                        <?php }elseif ($d['type'] == 3){?>
                                                                                                                    赠送
                        <?php }elseif ($d['type'] == 4){?>
                                                                                                                    调拨
                        <?php }elseif ($d['type'] == 5){?>
                                                                                                                    售卖
                        <?php }else{?>
                                                                                                                    使用
                        <?php }?>
                    </td>
                    <td><?=Html::encode($d['count']) ?></td>
                    <td>
                        <ul class="listInfo clearfix">
                            <?php for ($i=0; $i<count($d['record']);$i++ ){?>
                                <li class="pull-left"><?=Html::encode($d['record'][$i]) ?></li>
                            <?php }?>
                        </ul>
                    </td>
                    <td><a class="detal btn btn-sm btn-borB" dhref="<?=Url::toRoute(['goodsdec/decrecorddetal','unique_flag' => $d['unique_flag']]) ?>" href="javascript:void(0)">查看明细</a></td>
                </tr>
                <?php }?>
                </tbody>
            </table>

            
            <div class="page">
			<?=LinkPager::widget([
                'pagination' => $page,
	           'firstPageLabel' => '首页',
	           'nextPageLabel' => '下一页',
	           'prevPageLabel' => '上一页',
	           'lastPageLabel' => '末页',
            ]); ?>
            </div>
            <?php }?>
        </div>


    </div>

</div>
<?php $this->beginBlock('js_index_end') ?>
    $(function(){
laydate.skin('meelier');
	    function openPage() {
            var obj = $(this);
            var url = obj.attr('dhref');
            layer.open({
                type: 2,
                title: '',
                shadeClose: false,
                shade: 0.8,
                maxmin: true, //开启最大化最小化按钮
                area: ['65%', '65%'],
                content: url
            });
        }
       $('.detal').on('click', openPage);

        $('.listInfo').each(function(){
            $(this).children(":gt(2)").hide();
        })
    })
<?php $this->endBlock() ?>
<?php $this->registerJs($this->blocks['js_index_end'], $this::POS_END); ?>




